<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="../../../lib/html5shiv.js?rev=@@hash"></script>
    <script type="text/javascript" src="../../../lib/respond.min.js?rev=@@hash"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../../lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="../../../static/h-ui.admin/css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../../ht-css/Project.css"/>
    <!--[if IE 6]>
    <script type="text/javascript" src="../../../lib/DD_belatedPNG_0.0.8a-min.js?rev=@@hash"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <style>

        td.details-control {
            cursor: pointer;
        }

        tr.shown td.details-control {
        }
    </style>
    <![endif]-->
    <title>添加等级</title>
</head>
<body>
<article class="page-co222ntainer" style="width:96%">
    <form class="form form-horizontal mt-40" id="form-level">
        <div class="row cl">
            <label class="form-label w-150 f-l mr-10">可用积分:</label>
            <div class="formControls f-l change">
            <span id="waitIntegrals"></span>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label w-150 f-l mr-10">调整类型:</label>
            <div class="formControls f-l change">
                <select class="select" name="brandclass" id="order_ty1pe" size="1" style="width: 136px;height: 26px;">
                    <option value="" selected>请选择</option>
                    <option value="10">添加</option>
                    <option value="20">减少</option>
                </select>
            </div>
            <div class="formControls f-l change">
                <input id="moneyUpperLimit" name="moneyUpperLimit" style="margin-left: 27px;width: 136px;" onchange="requiredUp(this)" type="text" maxlength="15" autocomplete="off" class="input-text radius w-100"
                       required  onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}"
                       onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'0')}else{this.value=this.value.replace(/\D/g,'')}" oninput="kk()">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label w-150 f-l mr-10">调整原因:</label>
            <div class="formControls f-l change">
                <select class="select" size="1" name="sendReasonDutyDept"
                        id="sendReasonDutyDept"
                        onchange="sendDeptChange(value)" size="1" style="width: 136px;height: 26px;">
                    <option value="" selected>请选择责任部门</option>
                    <option value="1">商品问题</option>
                    <option value="2">仓储/物流问题</option>
                    <option value="3">财务问题</option>
                    <option value="4">网站运营问题</option>
                    <option value="5">服务体验问题</option>
                    <option value="6">运费问题</option>
                    <option value="7">技术问题</option>
                </select>
            </div>
            <div class="formControls f-l change">
                <select class="select" size="1" name="sendCouponReason" id="sendCouponReason"
                        style="width: 136px;height: 26px;margin-left: 27px;">
                    <option value="" selected>请选择具体原因</option><option class="options hide"  value="11">质量问题</option><option class="options hide" value="12">无货问题</option><option class="options hide" value="21">配送延迟</option><option class="options hide" value="22">状态维护错误</option><option class="options hide" value="23">私自拒收</option><option class="options hide" value="24">包装/商品破损</option><option class="options hide" value="25">违规收费</option><option class="options hide" value="26">服务态度差</option><option class="options hide" value="27">错漏发</option><option class="options hide" value="31">退款时效慢</option><option class="options hide" value="32">开票信息有误</option><option class="options hide" value="33">退款金额有误</option><option class="options hide" value="34">开具发票时间有误</option><option class="options hide" value="41">商品参数错误</option> <option class="options hide" value="42">价格错误</option> <option class="options hide" value="43">活动与实际不符</option> <option class="options hide" value="44">活动优惠券补发</option> <option class="options hide" value="45">活动优惠券发放</option><option class="options hide" value="51">特殊售后问题</option> <option class="options hide" value="52">提升客户体验</option> <option class="options hide" value="53">承诺错误</option> <option class="options hide" value="54">售后时间长</option><option class="options hide" value="61">售后运费补偿</option> <option class="options hide" value="62">错发运费补偿</option><option class="options hide" value="71">订单未流转</option> <option class="options hide" value="72">活动未绑定优惠品、赠品</option> <option class="options hide" value="73">系统自动取消</option> <option class="options hide" value="74">页面缓存问题</option>
                </select>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label w-150 f-l mr-10">调整归属:</label>
            <div class="formControls f-l change">
                <select class="select" name="brandclass" id="order_sy1pe" size="1" style="width: 300px;height: 26px;">
                    <script id="ascription_bob" type="text/x-dot-template">
                        <option disabled="disabled" selected>请选择</option>
                        {{if( it && it.length>0 ){ }}
                        {{ for(var i=0; i< it.length; i++) { }}
                        <option value="{{=it[i].id}}">{{=it[i].organization_name}}</option>
                        {{ } }}
                        {{ }else{ }}
                        <option>没有数据</option>
                        {{ } }}
                    </script>
                </select>
            </div>

        </div>
        <div class="row cl">
            <label class="form-label w-150 f-l mr-10">说明:</label>
            <div class="formControls f-l change">
                <textarea id="gradeExplain" name="gradeExplain" maxlength="200" style=" width: 300px; height: 170px;" class="input-text radius w-100 "
                           required></textarea>
                <span class="pos-r" style="left:0;top:70px;">（最多可输入200位）</span>
            </div>
        </div>
        <input type="text" id="gradeId" name="gradeId" value="0" hidden>
        <div class="row cl">
            <div style="margin-left:245px;">
                <input id="true" onclick="addThisIframe()" type="button" class="btn btn-secondary radius size-S" value="确定"/>
                <input type="button" class="btn radius ml-10" onclick="removeThisIframe()" value="取消">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="../../../lib/jquery/1.9.1/jquery.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/layer/2.4/layer.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui/js/H-ui.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../static/h-ui.admin/js/H-ui.admin.js?rev=@@hash"></script> <!--/_footer 作为公共模版分离出去-->
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<!--表单验证-->
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/jquery.validate.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/validate-methods.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/jquery.validation/1.14.0/messages_zh.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/Validform/5.3.2/Validform_v5.3.2_min.js?rev=@@hash"></script>
<script src="../../../lib/pagination/jquery.pagination.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/datatables/1.10.0/jquery.dataTables.min.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/laypage/1.2/laypage.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../lib/My97DatePicker/4.8/WdatePicker.js?rev=@@hash"></script>
<script src="../../../ht-js/public.js?rev=@@hash"></script>
<!--验证token-->
<script src="../../../ht-js/verifyToken.js?rev=@@hash"></script>
<script src="../../../ht-js/Project.js?rev=@@hash"></script>
<script type="text/javascript" src="../../../ht-js/frame/doT.min.js?rev=@@hash"></script>
<script>
    //初始化调整归属下拉列表
    ascription()
    function ascription() {
        var user_data = {
        }
        var succCallBack = function (data, status, response) {
            //console.log(data)
            if(data.errorCode=="0") {
                var dataInter=data.group;
                var interText = doT.template($("#ascription_bob").text());
                $("#order_sy1pe").html(interText(dataInter));
            }
        };
        return web.doAjax(root.inter.getGroup, 'post', user_data, succCallBack);
    }



    var rolename=""
    //获取部门
    user_cha()
    function user_cha(){
        $.ajax({
            type: "POST",
            url: root.accessInter.access_user_listUsersApi,
            xhrFields:{withCredentials:true,credentials:true},
            cache: false,  //禁用缓存
            dataType: "json",
            data: {
                NU:JSON.parse(web.readCookie("loginData")).user.name,
                PHONE:"",
                BM:"",
                entryTimeStart:"",
                entryTimeEnd:"",
                STATUS: "",
            },  //传入组装的参数
            success: function (data) {
                if(data!=""){
                    rolename=data.userList[0].ROLE_NAME
                }

            },
    })

    }


    //调整原因
    var oldVal ='';
    function sendDeptChange(Val){
        if(oldVal!=Val){
            $('#sendCouponReason').val('')
        }
        oldVal=Val;
        console.log(Val);
        var option = document.getElementsByClassName('options');
        console.log(option);
        switch (parseInt(Val)) {
            case 1:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value==11||option[i].value==12){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 2:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>20&&option[i].value<28){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 3:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>30&&option[i].value<35){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 4:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>40&&option[i].value<49){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 5:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>50&&option[i].value<59){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 6:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>60&&option[i].value<69){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
            case 7:
                for(var i=0 ; i<option.length ;i++)
                {
                    if(option[i].value>70&&option[i].value<79){
                        console.log(option[i]);
                        option[i].classList.remove('hide');
                    }
                    else{
                        option[i].classList.add('hide');
                    }
                }
                break;
        }
    }

    var waitIntegral = sessionStorage.getItem("waitIntegral");
    $("#waitIntegrals").html(waitIntegral)
    var memberId = sessionStorage.getItem("memberId");

    //确定
    function addThisIframe() {

        if($("#order_ty1pe ").val()==""){
            layer.msg("请选择调整类型", {
                icon: 2,
                time: 3000
            });
            return false;
        }else if($("#sendReasonDutyDept ").val()==""){

            layer.msg("请选择责任部门", {
                icon: 2,
                time: 3000
            });
            return false;
        }else if($("#sendCouponReason ").val()==""){

            layer.msg("请选择具体原因", {
                icon: 2,
                time: 3000
            });
            return false;

        }else if($("#order_sy1pe").val()==null){

            layer.msg("请选择调整归属", {
                icon: 2,
                time: 3000
            });
            return false;
        }if($("#gradeExplain").val()==""){

            layer.msg("请输入说明", {
                icon: 2,
                time: 3000
            });
            return false;
        }

       var sendReasonDutyDepts="";
       if($("#sendReasonDutyDept option:selected").html()=="请选择责任部门"){

           sendReasonDutyDepts=""
       }else {
           sendReasonDutyDepts=$("#sendReasonDutyDept option:selected").html()
       }
        var sendCouponReasons="";
        if($("#sendCouponReason option:selected").html()=="请选择具体原因"){

            sendCouponReasons=""
        }else {
            sendCouponReasons=$("#sendCouponReason option:selected").html()
        }


        $.ajax({
            url:root.member.handMoveIntegral,
            contentType: "application/json;charset=UTF-8",
            cache: false,  //禁用缓存
            type: "POST",
            dataType:'json',
            timeout:10000,
            data: JSON.stringify({
                "memberId":memberId,
                "belongGroupId":$("#order_sy1pe").val(),
                "type":$("#order_ty1pe").val(),
                "reason":"70",
                "clubClass":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                "clubName":rolename ,
                "detailedText":sendReasonDutyDepts+sendCouponReasons+$("#gradeExplain").val(),
                "totalIntegral":$("#moneyUpperLimit").val(),

            }),
            success: function (data) {
                if(data.errorCode==0){
                    layer.msg("修改成功",{icon: 6,time:2000},function () {
                        parent.location.reload(); // 父页面刷新
                        var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index);
                    });

                }
            },
            error: function () {
                $.Huimodalalert('失败！',2000);
            }
        });
    }
    /*关闭详情页*/
    function removeThisIframe() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

    function kk() {
        var sum = "";
        if ($("#moneyUpperLimit").val() > 1000000) {
            $.Huimodalalert('最大输入1000000！', 2000);
            $("#moneyUpperLimit").val("")
        }
    }

</script>

</body>
</html>